﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using com.loto.Common;

namespace com.huigo.Framework.ServiceUtils
{
    public class BaseService
    {
        public string ServiceAcc
        {
            get { return ConfigurationManager.AppSettings["ACC"]; }
        }

        public string ServicePin
        {
            get { return ConfigurationManager.AppSettings["PIN"]; }
        }

        public ParserXml RequestEntryService(Dict.ERequestFunc funcName, List<RequestFuncParams> paramsList)
        {
            if (paramsList != null)
            {
                RequestFunArgs rAddCart = new RequestFunArgs();
                foreach (RequestFuncParams p in paramsList)
                {
                    rAddCart.RequestArgList.Add(new RequestArg(p.Name, p.Value));
                }
                rAddCart.sFuncName = DictEnum.GetDictValueByKey(Dict.DRequestFunc, (int)funcName);
                return ParserEntryService(RequestXml.GetRequestXml(rAddCart));
            }
            else
                return null;
        }

        private string RequestEntryService(string req)
        {
            RequestService requestService = new RequestService();
            return requestService.RequestEntryService(req, ServiceAcc, ServicePin);
        }

        private ParserXml ParserEntryService(string req)
        {
            RequestService requestService = new RequestService();
            return new ParserXml(RequestEntryService(req));
        }

    }
}
